﻿using System;
using System.Collections.Generic;

using System.Text;

namespace DTO
{
    public partial class Customer : BaseDTO
    {
        #region Fields
        private double _amount;
        private IList<Device> _devices;
        #endregion

        #region Properties
        public string Code { get; set; }
        public string CompanyName { get; set; }
        public LocationInfo Location { get; set; }

        public string Fax { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }

        public Contact MainContact { get; set; }
        public IList<User> Users { get; set; }
        public IList<Contact> Contacts { get; set; }
        public IList<Device> Devices { get { return _devices; } }

        public DateTime NextPaymentOn { get; set; }
        public double Referrals { get; set; }
        public double BillingAmount { get { return _amount; } }
        public CreditCard BillingCard { get; set; }
        public Contact BillingContact { get; set; }

        public BandwidthInfo Bandwidth { get; set; }
        public DateTime Created { get; set; }

        #endregion

        #region Constructors
        public Customer () : this(0) { }
        public Customer ( int id ) : base(id)
        {
        }
        #endregion

        #region Private Methods
        #endregion

        #region Public Methods
        public void AddDevice (Device device)
        {
            if ( _devices == null )
                _devices = new List<Device>();

            _devices.Add(device);
            _amount += device.Fee;
        }

        public static Customer Sample ()
        {
            Customer customer = new Customer(4)
            {
                CompanyName = "Reliable Technologies, Inc.",
                MainContact = Contact.MainContactSample(),
                Created = DateTime.Parse("September 4, 2012, 2:48PM"),
                BillingCard = CreditCard.Sample(),
                BillingContact = Contact.BillingContact(),
                NextPaymentOn = DateTime.Parse("December 17, 2012"),
                Bandwidth = BandwidthInfo.Sample(),
                Contacts = new List<Contact>(),
                Users = new List<User>()
            };

            customer.Contacts.Add(Contact.Sample());

            customer.Users.Add(User.Sample1());
            customer.Users.Add(User.Sample2());

            customer.AddDevice(Device.Sample("DED3423", "", "", 1, 1));
            customer.AddDevice(Device.Sample("DED5423", "", "", 2, 2));
            customer.AddDevice(Device.Sample("DED3823", "", "", 3, 2));

            return customer;
        }
        #endregion

    }
}
